110 COMMON SP,FIN,D!,RK,RC,RB,RR!,RT!,KST,KB,KK,KC,G(),CX(),CY(),BX(),BY()
120 COMMON NS(),P(),UX,UY,RS,KR,RR,KS,CR,KP,Q(),KX(),KY(),KP!(),KA!(),KD!()
130 COMMON NK,NB,NR!,NC,NT!,NST,NE!,NSH!,NT,NL!,ND!,E!,S!,SU,C,T,S$
140 COMMON QX,QY,SX,SY,W!,WS!,L!,D!(),LN,S,P$,DS!,DR!,H!,T!,BX,BY,DF!
150 COMMON HK,KC,CS,NH,NKN,S(),F!(),GO,G1,A,JI,R,AD,DF!,SC,TX,TY,ND,PX,PY,O
160 COMMON LD,P,MN,NP,HE,HS,NZ,HR,CF,SN,CG,SB,SE,CP!,CT,DB,BAX,BAY,CR!(),DO,IN$
400 ZZZY=RND(1)*RND(1)*RND(1)*100 MOD 97:RANDOMIZE ZZZY
500 IF FIN=0 THEN GOTO 600
505 PRINT:PRINT:PRINT:PRINT "It is stardate ";:PRINT USING "####.#";D!;:PRINT ".":PRINT
510 ON FIN GOSUB 1000,1200,1240,1290,1320,1350,1380,1420,1450,1480,1510,1540,1570,1600,1640,1670,1710,1750,1780,1810,1840
520 IF (FIN>=3 AND FIN<=5) OR FIN>=7 THEN GOSUB 1900
550 GOSUB 2000:'score
600 PRINT STRING$(79,"*")
605 I$=INKEY$:IF I$<>"" THEN 605
610 PRINT "Would you like to play again ? ";
620 I$=INKEY$:IF I$="" THEN 620
630 IF I$="Y" OR I$="y" THEN PRINT "Yes":CLEAR:RUN "TREKINIT" ELSE PRINT "No"
650 SYSTEM
1000 'game won
1010 IF RR<>0 THEN PRINT "The remaining"RR"Romulans surrender to starfleet command.":PRINT
1020 PRINT "You have smashed the Klingon invasion fleet and saved the Federation."
1030 G1=1:IF A=0 OR KB<>0 OR LEFT$(S$,1)<>"E" OR 5*KST+CS+10*KP+45*NH>=100 THEN 1180
1040 IF D!-ND!<5 THEN 1060
1050 RATEMX!=0.1*S*(S+1)+0.1:PERDTE!=(KK+KC+KS)/(D!-ND!):IF PERDTE!<RATEMX! THEN 1180
1060 PRINT:PRINT "In fact, you have done so well that Starfleet Command ";
1070 IF S=4 THEN 1110 ELSE IF S=5 THEN 1120
1080 PRINT "promotes you one step in":PRINT "rank from ";
1090 IF S=1 THEN PRINT "'Novice' to 'Fair'"; ELSE IF S=2 THEN PRINT "'Fair' to 'Good'"; ELSE PRINT "'Good' to 'Expert'";
1100 PRINT " ... CONGRATULATIONS !":GOTO 1180
1110 PRINT "promotes you to":PRINT " Commodore Emeritus.":PRINT:PRINT "Now that you think you're really good, try playing the 'Emeritus'":PRINT "game. It will splatter your ego !":GOTO 1180
1120 DLY=100:GOSUB 1870:PRINT:PRINT "Computer: ERROR-ERROR-ERROR-ERROR":PRINT "YOUR SKILL HAS EXCEEDED THE CAPACITY OF THES PROGRAM."
1130 MSG$="THIS PROGRAM MUST SURVIVE":FOR I=1 TO 3:DLY=80*I:GOSUB 1870:PRINT MSG$:NEXT I
1140 ML=LEN(MSG$):FOR I=1 TO ML:PRINT MID$(MSG$,I,1);:DLY=RND(1)*80:GOSUB 1870:IF I>0.75*ML THEN PRINT SPACE$((10+I-ML)*RND(1));
1150 NEXT I
1160 DLY=400:GOSUB 1870
1170 PRINT "Now you can retire and write your own Star Trek game.":
1180 PRINT:PRINT "Live long and prosper."
1190 RETURN
1200 'time run out
1210 PRINT "Your time has run out, and the Federation has been conquered. Your starship":PRINT "is now Klingon property, and you are put on trial as a war criminal. On the":PRINT "basis of your record you are ";
1220 IF RK*3>NK THEN PRINT "acquitted.":PRINT:PRINT "Live long and prosper." ELSE PRINT "found guilty and sentenced to death by slow":PRINT "torture.":A=0
1230 RETURN
1240 'life support system failure
1250 PRINT "Your life support reserves have run out."
1260 PRINT "You die of thirst, starvation and asphyxiation."
1270 PRINT "Your starship is a derelict in space."
1280 RETURN
1290 'energy supply exhausted
1300 PRINT "Your energy supply is exhausted":GOTO 1260
1310 RETURN
1320 'defeated in battle
1330 PRINT "The "S$" has been destroyed in battle.":PRINT:PRINT "Dulce et decorum est pro patria mori."
1340 RETURN
1350 'hit -energy barrier 3 times
1360 PRINT "You have made three attempts to cross the negative energy barrier which":PRINT "surrounds the galaxy.":PRINT:PRINT "Your navigation is abominable."
1370 RETURN
1380 'starship destroyed by ordinary nova
1390 PRINT "Your starship has been destroyed by a nova."
1400 PRINT "That was a great shot !!!"
1410 RETURN
1420 'starship destroyed by super nova
1430 PRINT "The "S$" has been fried by a supernova.":PRINT "...NOT EVEN CINDERS REMAIN..."
1440 RETURN
1450 'abandon ship when no starbases
1460 PRINT "You have been captured by the Klingons. If you still had a starbase to be":PRINT "returned to, you would have been repatriated and given another chance.":PRINT "Since you have no starbases, you will be mercilessly tortured to death.":A=0
1470 RETURN
1480 'starship self-destruct or dilithium crystals explode
1490 PRINT "Your starship is now an expanding cloud of subatomic particles."
1500 RETURN
1510 'failed to re-materialize after calling for help
1520 PRINT "Starbase was unable to re-materialize your starship."
1530 RETURN
1540 'starship phasers itself
1550 PRINT "The "S$" has been creamated by its own phasers."
1560 RETURN
1570 'captain lost in transporter beam
1580 PRINT "You and your landing party have been converted to energy, dissipating":PRINT "through space.":GOTO 1620
1590 RETURN
1600 'mining party left on planet after tractor beam
1610 PRINT "You are left with your landing party on a wild jungle planet inhabited by":PRINT "primitave cannibals.":PRINT:PRINT "They are very fond of 'Captain Kirk' soup."
1620 PRINT:PRINT "Without your leadership, the "S$" is destroyed."
1630 RETURN
1640 'starship destroys planet with mining party on it
1650 PRINT "You and your mining party perish.":GOTO 1400
1660 RETURN
1670 'Kirk fried by nova on planet surface
1680 PRINT "You and your mining party are instantly atomized."
1690 PRINT "Mr. Spock takes command of the "S$" and joins the Romulans, reigning":PRINT "terror on the federation."
1700 RETURN
1710 'Kirk fried by supernova in shuttle craft
1720 PRINT "Galileo is instantly annihilated by the supernova."
1730 TO TO 16000
1740 RETURN
1750 'shuttle craft caught in tractor beam
1760 PRINT "Shuttle craft Galileo is also caught, and breaks up under the strain.":PRINT:PRINT "Your debris is scattered for millions of miles.":GOTO 1620
1770 RETURN
1780 'deathray converts crew into mutants
1790 PRINT "The mutants attack and kill Spock. Your ship is captured by Klingons, and":PRINT:PRINT "your crew is put on display in a Klingon zoo."
1800 RETURN
1810 'tribble trouble
1820 PRINT "Tribbles consume all remaining water, food and oxygen on your ship.":GOTO 1260
1830 RETURN
1840 'black hole swallows ship
1850 PRINT "Your ship is drawn to the center of the black hole. You are crushed into":PRINT "extremely dense matter."
1860 RETURN
1870 'DELAY
1880 FOR DLYI=1 TO DLY:FOR DLYJ=1 TO 1:NEXT DLYJ,DLYI:RETURN
1900 PRINT:IF LEFT$(S$,1)="F" THEN S$="" ELSE IF LEFT$(S$,1)="E" THEN S$="Faire queen"
1920 PRINT "As a result of your actions, a treaty with the Klingon Empire has been":PRINT "signed. The terms of the treaty are ";
1925 IF ADVNTG!<3+RND(1) THEN 1935
1930 PRINT "favorable to the Federation.":PRINT:PRINT "CONGRATULATIONS.":RETURN
1935 PRINT "highly unfavorable to the Federation.":RETURN
1940 PRINT "The Federation will be destroyed."
1945 RETURN
1950 PRINT "Since you took the last Klingon with you, you are a martyr and a hero.":PRINT "Someday maybe they'll erect a statue in your memory. Rest in peace, and try":PRINT "not to think about pigeons.":G1=1:A=0
1955 RETURN
2000 ' score
2005 I$=INKEY$:IF I$<>"" THEN 2005
2010 PRINT:PRINT "=====> Press any key for score";
2020 I$=INKEY$:IF I$="" THEN 2020 ELSE LOCATE ,1:PRINT SPACE$(79);:LOCATE ,1
2030 TIMUSD!=D!-ND!:IF TIMUSD!=0 OR RK<>0 THEN IF TIMUSD!<5 THEN TIMUSD!=5
2110 IF KR<>0 THEN MSG$="Romulan(s) destroyed":SCR=20*KR:AMT=KR:GOSUB 5000
2120 IF RR<>0 THEN MSG$="Romulan(s) captured":SCR=RR:AMT=RR:GOSUB 5000
2130 IF KK<>0 THEN MSG$="Ordinary Klingon(s) destroyed":SCR=KK*10:AMT=KK:GOSUB 5000
2140 IF KC<>0 THEN MSG$="Klingon Commander(s) destroyed":SCR=50*KC:AMT=KC:GOSUB 5000
2150 IF KS<>0 THEN MSG$="Super-Commander destroyed":SCR=200:AMT=-1:GOSUB 5000
2160 IF ITHPRD<>0 THEN PRINT USING "###.# Klingons per stardate average";PERDTE!;:PRINT STRING$(54-POS(0),".");:PRINT USING "##,###";ITHPRD
2170 IF KST<>0 THEN MSG$="star(s) destroyed by your action":SCR=-5*KST:AMT=KST:GOSUB 5000
2180 IF KP<>0 THEN MSG$="planet(s) destroyed by your action":SCR=-10*KP:AMT=KP:GOSUB 5000
2190 IF KB<>0 THEN MSG$="base(s) destroyed by your action":SCR=-100*KB:AMT=KB:GOSUB 5000
2200 IF NH<>0 THEN MSG$="call(s) for help from starbase":SCR=-45*NH:AMT=NH:GOSUB 5000
2210 IF CS=0 THEN 2220
2212 IF CS=1 THEN MSG$="casualty incurred" ELSE MSG$="casualties incurred"
2214 SCR=-CS:AMT=CS:GOSUB 5000
2220 IF KLSHIP<>0 THEN MSG$="ship(s) lost or destroyed":SCR=-100*KLSHIP:AMT=KLSHIP:GOSUB 5000
2230 IF A=0 THEN MSG$="Penalty for getting yourself killed":SCR=-200:AMT=-1:GOSUB 5000
2240 IF G1=0 THEN 2250
2242 MSG$="Bonus for winning "
2244 IF S=1 THEN MSG$=MSG$+"novice" ELSE IF S=2 THEN MSG$=MSG$+"fair" ELSE IF S=3 THEN MSG$=MSG$+"good" ELSE IF S=4 THEN MSG$=MSG$+"expert" ELSE MSG$=MSG$+"emeritus"